package com.mini.demos.webgame.codec;

import org.apache.mina.core.buffer.IoBuffer;

import com.mini.demos.webgame.msg.AbstractGameMsg;
import com.mini.demos.webgame.msg.JobListMsgResp;
import com.mini.demos.webgame.util.Constants;
import com.mini.framework.communicate.mina.protocol.Msg;

public class JobListRespEncoder extends AbstractEncoder {

	@Override
	public void encodeBody(AbstractGameMsg msg, IoBuffer buffer) {
		JobListMsgResp jobListMsgResp = (JobListMsgResp)msg;
		buffer.putInt(jobListMsgResp.getCode().intValue());
		try{
			buffer.putString(jobListMsgResp.getJobXmlBody(), Constants.charset.newEncoder());
		}catch(Exception e){
			e.printStackTrace();
		}
	}

	@Override
	public Class<? extends Msg> getMsgType() {
		
		return JobListMsgResp.class;
	}

}
